package com.home.free.service.impl;

import com.home.free.fectory.user.BuildUserVo;
import com.home.free.entity.User;
import com.home.free.manager.UserManager;
import com.home.free.service.UserService;
import com.home.free.vo.user.UserQuery;
import com.home.free.vo.user.UserVo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Title: com.home.free.service.impl<br>
 * Description: <br>
 * Copyright: Copyright (c) 2015<br>
 * Company: 北京云杉世界信息技术有限公司<br>
 *
 * @author gaotianjie
 * @date 2019/3/19
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserManager userManager;

    @Override
    public User selectUserById(Long id) {
        return userManager.selectUserById(id);
    }

    @Override
    public List<User> selectAllUserList() {
        return userManager.selectAllUserList();
    }

    @Override
    public List<UserVo> pageUserList(UserQuery userQuery) {
        List<User> userList = userManager.pageUserList(userQuery);
        if (CollectionUtils.isNotEmpty(userList)) {
            return BuildUserVo.buildUserVoPage(userList);
        }

        return new ArrayList<>();
    }

    @Override
    public Integer pageUserCount(UserQuery userQuery) {
        return userManager.pageUserCount(userQuery);
    }

    @Override
    public Integer saveUser(UserVo userVo) {

        User user = BuildUserVo.buildUserVoToUser(userVo);

        return null;
    }
}
